import Vue from 'vue'
import { getDictItemsValue } from '@api/api'

export const DictMixin = {
  data () {
    return {
      description: '获取字典信息',
      /**表单回显数据*/
      _dictTextData: {},
    }
  },
  methods: {
    _dictText (val, code, fun) {
      let that = this
      if (val && code) {
        // await
        getDictItemsValue({dictCode: code, key: val}).then((res) => {
          if (res.success) {
            that.$data._dictTextData[fun] = res.result
            that.$forceUpdate()
          }
        })
      }
    },
  }
}